{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[Table of Contents](./table_of_contents.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# H Infinity filter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style>\n",
       "        .output_wrapper, .output {\n",
       "            height:auto !important;\n",
       "            max-height:100000px; \n",
       "        }\n",
       "        .output_scroll {\n",
       "            box-shadow:none !important;\n",
       "            webkit-box-shadow:none !important;\n",
       "        }\n",
       "        </style>\n",
       "    "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#format the book\n",
    "import book_format\n",
    "book_format.set_style()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I am still mulling over how to write this chapter. In the meantime, Professor Dan Simon at Cleveland State University has an accessible introduction here:\n",
    "\n",
    "http://academic.csuohio.edu/simond/courses/eec641/hinfinity.pdf\n",
    "\n",
    "In one sentence the $H_\\infty$ (H infinity) filter is like a Kalman filter, but it is robust in the face of non-Gaussian, non-predictable inputs.\n",
    "\n",
    "\n",
    "My FilterPy library contains an H-Infinity filter. I've pasted some test code below which implements the filter designed by Simon in the article above. Hope it helps."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEICAYAAABGaK+TAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAo4ElEQVR4nO3deXhc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w97vC/wQr3P1TGVTfZ4Fed/9COmpKZmbzgfnu/rSZlQJbgDcA7yEDtuEZ6nsLGbANLZh1rsTde80sH3gUuAP4fTJj+52uvlvIgO13LrJhD/xyYKe773b3IeD7wOvTXFNGc/eHgY5TVr8e+Ga4/E2CX/i0OE19GcPdj7j70+FyD9AELCRDtuEZ6ssIHugNb+aHFydztt/p6ss62RDgC4EDSbcPkkEf1pADvzazLWZ2e7qLOY0adz8CQQAAkTTXM5oPm9mz4RBL2oZ4kpnZMuBi4EkycBueUh9kyDY0s1wzewaIAve7e0Ztv9PUBxmy/cYqGwJ8tEnAM+1/y2vc/RLg1cCHwiECOTdfBlYAFwFHgL9LazWAmc0GfgR8xN27013PqUapL2O2obvH3f0iYBFwuZmtSVctozlNfRmz/cYqGwL8ILA46fYi4HCaahmVux8Or6PAfxEM+2SalnDsdGQMNZrmek7i7i3hL1UC+Cpp3obh2OiPgO+6+4/D1RmzDUerL9O2YVjTUWATwfhyxmy/Ecn1ZeL2O5tsCPCngFVmdp6ZFQBvA+5Lc03HmVlJ+EUSZlYC3Aw8f+ZnpcV9wLvD5XcDP01jLS8z8osdeiNp3Ibhl1xfA5rc/YtJd2XENjxdfZmyDc2s2szmhMvFwHqgmczZfqPWlynb71xk/FEoAOHhPP8A5AL3uPvn01vRCWa2nGCvG4IWdfemuz4z+x6wjmB6zBbgL4GfAD8ElgD7gTe7e1q+SDxNfesI/nR1YC/wRyPjpWmo71rgEeA5IBGu/gzBOHPat+EZ6ns7GbANzewCgi8pcwl2En/o7n9lZpVkxvY7XX3fJgO237nIigAXEZGXy4YhFBERGYUCXEQkSynARUSylAJcRCRLKcBFRLKUAlxEJEspwEVEstT/B9Z0G1FVpYvbAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from filterpy.hinfinity import HInfinityFilter\n",
    "\n",
    "dt = 0.1\n",
    "f = HInfinityFilter(2, 1, dim_u=1, gamma=.01)\n",
    "\n",
    "f.F = np.array([[1., dt],\n",
    "                [0., 1.]])\n",
    "\n",
    "f.H = np.array([[0., 1.]])\n",
    "f.G = np.array([[dt**2 / 2, dt]]).T\n",
    "\n",
    "f.P = 0.01\n",
    "f.W = np.array([[0.0003, 0.005],\n",
    "                [0.0050, 0.100]])/ 1000  #process noise\n",
    "\n",
    "f.V = 0.01\n",
    "f.Q = 0.01\n",
    "u = 1. #acceleration of 1 f/sec**2\n",
    "\n",
    "xs = []\n",
    "vs = []\n",
    "\n",
    "for i in range(1,40):\n",
    "    f.update (5)\n",
    "    #print(f.x.T)\n",
    "    xs.append(f.x[0,0])\n",
    "    vs.append(f.x[1,0])\n",
    "    f.predict(u=u)\n",
    "\n",
    "plt.subplot(211)\n",
    "plt.plot(xs)\n",
    "plt.title('position')\n",
    "plt.subplot(212)\n",
    "plt.plot(vs) \n",
    "plt.title('velocity');"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
